<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    //  bubbleSort 冒泡排序
       let arr = [1,5,8,9,10,5,9]
       function bubbleSort(arr){
         let len = arr.length
         for(let i = 0;i<len - 1;i++){
           for( let j = 0;j<len-1-i;j++){
             if(arr[j]>arr[j+1]){
              //  [arr[j],arr[j+1]] = [arr[j+1],arr[j]]
              swap(arr,i,j)
             }
           }
         }
         return arr
       }


  function swap(arr,a,b){
    let temp = arr[a]
    arr[a] = arr[b]
    arr[b] = temp
  }
  </script>
</body>
</html>